﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nage.Algorithms;
using Nage.Algorithms.Solution;
using Microsoft.Practices.Unity;

namespace Nage.Examples.Rastrigin.Solution
{
    public class Coordinates : ISolution
    {
        #region Public properties
        /// <summary>
        /// X coordinate
        /// </summary>
        public double[] Vector { get; set; }
        /// <summary>
        /// Fitness
        /// </summary>
        public double Fitness { get; set; }
        #endregion

        #region Constructors
        [InjectionConstructor]
        public Coordinates()
        {
        }

        public Coordinates(double[] vector)
        {
            this.Vector = vector;
        } 
        #endregion

        #region GetRepresentation
        public object GetRepresentation()
        {
            return Vector;
        } 
        #endregion

        #region ToString
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder("( ");
            for (int i = 0; i < Vector.Length - 1; i++)
            {
                sb.AppendFormat("{0} ; ", Vector[i].ToString("0.00000"));
            }
            sb.AppendFormat("{0} )", Vector.Last().ToString("0.00000"));
            return sb.ToString();
        } 
        #endregion
    }
}
